package com.example.jiemian;

import android.content.Intent;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTabHost;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class indexActivity extends AppCompatActivity {
    private FragmentTabHost tabHost;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_index);
        //初始化框架对象
        init();
        //设置Tab
        setTab();
    }

    public void init() {
        tabHost=(FragmentTabHost)findViewById(R.id.tabHost);
    }

    public void setTab(){
        //通过tab显示框架的不同内容
        FragmentManager fragmentManager=getSupportFragmentManager();

        tabHost.setup(this,fragmentManager,R.id.tablocation);
        tabHost.getTabWidget().setDividerDrawable(null);
        //设置tab相关属性（页面，所调用的类文件，null）
        tabHost.addTab(tabHost.newTabSpec("shishjiankong").setIndicator(setTabview("实施环境")),ceshi2.class,null);
        tabHost.addTab(tabHost.newTabSpec("dieye").setIndicator(setTabview("设备控制")),ceshi3.class,null);
        tabHost.addTab(tabHost.newTabSpec("dye").setIndicator(setTabview("数据分析")),ceshi5.class,null);
        tabHost.addTab(tabHost.newTabSpec("e").setIndicator(setTabview("参数设置")),ceshi.class,null);
    }

    //创建null视图界面
    public View setTabview(String title){
        //通过xml创建不同tab标签
        View view= LayoutInflater.from(this).inflate(R.layout.kongbai,null);
        //获取模板当中的文本内容
        TextView textView=(TextView)view.findViewById(R.id.tabtool_textview_title);
        //设置标签
        textView.setText(title);
        return view;
    }


}
